/**
 * Copyright (c) 2018 人人开源 All rights reserved.
 *
 * https://www.renren.io
 *
 * 版权所有，侵权必究！
 */

package com.chengke.commom.utils;


/**
 * excel工具类
 *
 * @author Mark sunlightcs@gmail.com
 */
public class ExcelUtils {
//
//    /**
//     * Excel导出
//     *
//     * @param response      response
//     * @param fileName      文件名
//     * @param list          数据List
//     * @param pojoClass     对象Class
//     */
//    public static void exportExcel(HttpServletResponse response, String fileName, Collection<?> list,
//                                     Class<?> pojoClass) throws IOException {
//        if(StringUtils.isBlank(fileName)){
//            //当前日期
//            fileName = DateUtils.format(new Date());
//        }
//
//        Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams(), pojoClass, list);
//        response.setCharacterEncoding("UTF-8");
//        response.setHeader("content-Type", "application/vnd.ms-excel");
//        response.setHeader("Content-Disposition",
//                "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8") + ".xls");
//        ServletOutputStream out = response.getOutputStream();
//        workbook.write(out);
//        out.flush();
//    }
//
//    /**
//     * Excel导出，先sourceList转换成List<targetClass>，再导出
//     *
//     * @param response      response
//     * @param fileName      文件名
//     * @param sourceList    原数据List
//     * @param targetClass   目标对象Class
//     */
//    public static void exportExcelToTarget(HttpServletResponse response, String fileName, Collection<?> sourceList,
//                                     Class<?> targetClass) throws Exception {
//        List targetList = new ArrayList<>(sourceList.size());
//        for(Object source : sourceList){
//            Object target = targetClass.newInstance();
//            BeanUtils.copyProperties(source, target);
//            targetList.add(target);
//        }
//
//        exportExcel(response, fileName, targetList, targetClass);
//    }
}
